<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./LogInTemplate.xhtml">

            <ui:define name="top">
                <p:panel>
                <br/>
                <h1>
                    <p:outputLabel value="Create/Edit User..."/>
                </h1>
                <br/>
                <br/>
                </p:panel>
                
            </ui:define>

            <ui:define name="content">
                <f:view>
                    <h:form>
                        <center>
                            <p:panel><p:growl/>

                                <h:panelGrid columns="2">
                                    <p:outputLabel value="Control Number:" for="controlNumber" />
                                    <p:inputMask id="controlNumber" mask="9999-9999" value="#{studentBean.student.controlNumber}" required="true" requiredMessage="The Control Number field is required."/>
                                    <p:outputLabel value="Name:" for="name" />
                                    <p:inputText id="name" value="#{studentBean.student.name}" title="Name" required="true" requiredMessage="The Name field is required." validatorMessage="Incorrect Data">
                                        <f:validateRegex pattern="^[A-Za-z\s]+$"/>
                                    </p:inputText>
                                    <p:outputLabel value="First name:" for="firstname" />
                                    <p:inputText id="firstname" value="#{studentBean.student.firstname}" title="Firstname" required="true" requiredMessage="The First name field is required." validatorMessage="Incorrect Data">
                                        <f:validateRegex pattern="^[A-Za-z\s]+$"/>
                                    </p:inputText>
                                    <p:outputLabel value="Last name:" for="lastname" />
                                    <p:inputText id="lastname" value="#{studentBean.student.lastname}" title="Lastname" validatorMessage="Incorrect Data">
                                        <f:validateRegex pattern="(^[A-Za-z\s]+$)?"/>
                                    </p:inputText>

                                    <p:outputLabel value="Id Course:" for="idCourse" />
                                    <p:selectOneMenu id="idCourse" value="#{studentBean.selectedCourse}" required="true" requiredMessage="The Id Course field is required." >
                                        <!-- TODO: update below reference to list of available items-->
                                        <f:selectItems value="#{courseBean.courseList}" var="item" itemLabel="#{item.name}" itemValue="#{item.id}"/>
                                    </p:selectOneMenu>
                                    <p:commandButton action="#{studentBean.processSelection}" value="Accept" ajax="false"/>
                                    <p:commandButton action="StudentList" value="Cancel" immediate="true"/>                            
                                </h:panelGrid>
                            </p:panel>
                        </center>
                    </h:form>
                </f:view>

            </ui:define>

        </ui:composition>

    </body>
</html>
